function item_price_or_cost_wave_approve_level(approve_wave) {
    var wave_percent_approve_list = []
    var approve_wave_list = approve_wave.split(',')
    approve_wave_list.forEach(function (wave) {
        var wave_list = wave.split(':')
        var wavePercent = wave_list[0]
        var wavePercentApprove = {
            wavePercent: wavePercent,
            approve: wave_list[1],
            symbolFlag: '+',
            waveStart: '',
            waveEnd: ''
        }

        if (wavePercent.indexOf("~") != -1) {
            var waveEnd = '';
            var waveStart = '';
            var wavePercentSplit = wavePercent.split("~");
            if (wavePercent.indexOf('-') != -1) {
                wavePercentApprove.symbolFlag = '-';
                waveStart = wavePercentSplit[1].replace('%', '');
                waveEnd = wavePercentSplit[0].replace('%', '');
                wavePercentApprove.waveStart = percent(waveStart);
                wavePercentApprove.waveEnd = percent(waveEnd)
            } else {
                waveStart = wavePercentSplit[0].replace('%', '');
                waveEnd = wavePercentSplit[1].replace('%', '');
                wavePercentApprove.waveStart = percent(waveStart);
                wavePercentApprove.waveEnd = percent(waveEnd)
            }
        } else {
            if (wavePercent.indexOf('-') != -1) {
                wavePercentApprove.symbolFlag = '-';
                wavePercentApprove.waveStart = -9999999999;
                wavePercentApprove.waveEnd = percent(wavePercent)
            } else {
                wavePercentApprove.waveStart = percent(wavePercent);
                wavePercentApprove.waveEnd = 9999999999
            }
        }
        wave_percent_approve_list.push(wavePercentApprove);
    })
    var wave_percent_approve_list_map = groupBy(wave_percent_approve_list, function (item) {
        return item.symbolFlag;
    });
    return wave_percent_approve_list_map;
}

function groupBy(array, keyFn) {
    return array.reduce(function (grouped, item) {
        var key = keyFn(item);
        grouped[key] = grouped[key] || [];
        grouped[key].push(item);
        return grouped;
    }, {});
}

function percent(wave) {
    return parseFloat((wave.replace('%', '') / 100).toFixed(2))
}
// var item_price_or_cost_wave_approve_level11 = JSON.parse('{"CODE":0, "ACTION":"","LEVEL":"T1", "MSG":"","DATA":"","SCRIPTNAME":"compare_retail_tax_or_cost_up_forbid_discount"}');
// var tr = item_price_or_cost_wave_approve_level(approve_wave)
// item_price_or_cost_wave_approve_level11.CODE = 2;
// item_price_or_cost_wave_approve_level11.ACTION = 'error';
// item_price_or_cost_wave_approve_level11.MSG = tr;
// JSON.stringify(item_price_or_cost_wave_approve_level11);
